package com.hu.common.util.adm;

import cn.hutool.core.util.ObjectUtil;
import com.hu.common.util.response.RespCode;


/**
 * @author 00351634
 * @version 1.0
 * @date 2024/9/29 7:47
 * @description: 断言工具类
 */
public class Asserts {
    /**
     * 断言对象是否不为{@code empty} ，如果为{@code empty} 抛出{@link IllegalArgumentException} 异常
     *
     * <pre class="code">
     * Assert.notEmpty(clazz);
     * </pre>
     *
     * @param object 被检查对象
     * @return 非空对象
     * @throws IllegalArgumentException if the object is {@code empty}
     */
    public static void notEmpty(Object object, RespCode respCode) throws IllegalArgumentException {
        if (ObjectUtil.isEmpty(object)) {
            throw respCode.toCodeException();
        }
    }

    /**
     * 断言对象是否不为{@code empty} ，如果为{@code empty} 抛出{@link IllegalArgumentException} 异常
     *
     * <pre class="code">
     * Assert.notEmpty(clazz);
     * </pre>
     *
     * @param object 被检查对象
     * @return 非空对象
     * @throws IllegalArgumentException if the object is {@code empty}
     */
    public static void notEmpty(Object object, RespCode respCode, Object... params) throws IllegalArgumentException {
        if (ObjectUtil.isEmpty(object)) {
            throw respCode.toCodeExceptionWithArgs(params);
        }
    }
}
